<include file="Public/mobile_head"/>
<link href="{:ADDON_PUBLIC_PATH}/css.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
<body>
<div id="container" class="container">
	<div class="lead_box">
		<div class="lead_content do">
			<span class="quote">NO.{$num}</span>
			<h6 class="a_title">{$question.title}</h6>

			<p class="w_tips">{$question.intro}</p>

			<form class="answer_form" id="form" action="{:U('survey?id='.$_GET['id'].'&next_id='.$next_id)}"
			      method="post">
				<input name="next_id" value="{$next_id}" type="hidden">
				<input name="question_id" value="{$question.id}" type="hidden">
				<input name="num" value="{$num}" type="hidden">
				<switch name="question.type">
					<case value="textarea">
						<!-- 文本框 -->
						<div class="form-item textarea-item cf">
							<div class="controls">
								<textarea type="text" placeholder="在这里输入内容" class="text input-medium" name="answer">{$data}</textarea>
							</div>
						</div>
					</case>
					<case value="checkbox">
						<volist name="extra" id="vo">
							<div class="form-item cf">
								<label class="checkbox"><span class="li_style">{$i}</span> <input type="checkbox"
								                                                                  value="{$key}"
								                                                                  name="answer[]"
									<in name="key" value="$data">checked="checked"</in>
									>{$vo} <span class="checked">&nbsp;</span></label>
							</div>
						</volist>
					</case>
					<default/>
					<volist name="extra" id="vo">
						<div class="form-item cf">
							<label class="radio"><span class="li_style">{$i}</span> <input type="radio" value="{$key}"
							                                                               name="answer"

								<eq name="data" value="$key">checked="checked"</eq>
								>{$vo} <span class="checked">&nbsp;</span></label>
						</div>
					</volist>
				</switch>
		</div>
		<if condition="($next_id eq -1)">
			<a class="lead_btn next_btn" id="submit" type="submit">完成</a>
			<else/>
			<a class="lead_btn next_btn" id="submit" type="submit">下一题</a>
		</if>
		</form>
	</div>
	<p class="copyright">{$system_copy_right}{$tongji_code}</p>
	<script type="text/javascript">
		var is_require = "{$question.is_must}";
		var widget = "{$question.type}";
		function checkForm() {
			if (is_require == '0') return true;

			var content = '';
			var msg = '当前的题目是必选题,请先选择选项.';
			if (widget == 'textarea') {
				content = $('textarea').val();
				msg = '当前的题目不能为空.';
			} else if (widget == 'checkbox') {
				content = $("input[type='checkbox']:checked").val();
			} else {
				content = $("input[type='radio']:checked").val();
			}
			//console.log(content);
			//return false;
			if (content == '' || content == undefined) {
				$.Dialog.fail(msg);
				return false;
			}

			return true;
		}
		$('#submit').click(function () {
			if (checkForm()) {
				$('#form').submit();
			}
		})
	</script>
</body>
</html>